@@ -20,11 +20,11 @@ module TwitterConcern |
||
| 20 | 20 |
end |
| 21 | 21 |
|
| 22 | 22 |
def twitter_consumer_key |
| 23 |
- ENV['TWITTER_OAUTH_KEY'] |
|
| 23 |
+ (config = Devise.omniauth_configs[:twitter]) && config.strategy.consumer_key |
|
| 24 | 24 |
end |
| 25 | 25 |
|
| 26 | 26 |
def twitter_consumer_secret |
| 27 |
- ENV['TWITTER_OAUTH_SECRET'] |
|
| 27 |
+ (config = Devise.omniauth_configs[:twitter]) && config.strategy.consumer_secret |
|
| 28 | 28 |
end |
| 29 | 29 |
|
| 30 | 30 |
def twitter_oauth_token |
@@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base |
||
| 27 | 27 |
private |
| 28 | 28 |
|
| 29 | 29 |
def twitter_oauth_check |
| 30 |
- if ENV['TWITTER_OAUTH_KEY'].blank? || ENV['TWITTER_OAUTH_SECRET'].blank? |
|
| 30 |
+ unless Devise.omniauth_providers.include?(:twitter) |
|
| 31 | 31 |
if @twitter_agent = current_user.agents.where("type like 'Agents::Twitter%'").first
|
| 32 | 32 |
@twitter_oauth_key = @twitter_agent.options['consumer_key'].presence || @twitter_agent.credential('twitter_consumer_key')
|
| 33 | 33 |
@twitter_oauth_secret = @twitter_agent.options['consumer_secret'].presence || @twitter_agent.credential('twitter_consumer_secret')
|
@@ -36,7 +36,7 @@ class ApplicationController < ActionController::Base |
||
| 36 | 36 |
end |
| 37 | 37 |
|
| 38 | 38 |
def basecamp_auth_check |
| 39 |
- if ENV['THIRTY_SEVEN_SIGNALS_OAUTH_KEY'].blank? || ENV['THIRTY_SEVEN_SIGNALS_OAUTH_SECRET'].blank? |
|
| 39 |
+ unless Devise.omniauth_providers.include?(:'37signals') |
|
| 40 | 40 |
@basecamp_agent = current_user.agents.where(type: 'Agents::BasecampAgent').first |
| 41 | 41 |
end |
| 42 | 42 |
end |
@@ -1,6 +1,4 @@ |
||
| 1 | 1 |
class Service < ActiveRecord::Base |
| 2 |
- PROVIDER_TO_ENV_MAP = {'37signals' => 'THIRTY_SEVEN_SIGNALS'}
|
|
| 3 |
- |
|
| 4 | 2 |
attr_accessible :provider, :name, :token, :secret, :refresh_token, :expires_at, :global, :options, :uid |
| 5 | 3 |
|
| 6 | 4 |
serialize :options, Hash |
@@ -51,16 +49,12 @@ class Service < ActiveRecord::Base |
||
| 51 | 49 |
URI.join(client_options['site'], client_options['token_url']) |
| 52 | 50 |
end |
| 53 | 51 |
|
| 54 |
- def provider_to_env |
|
| 55 |
- PROVIDER_TO_ENV_MAP[provider].presence || provider.upcase |
|
| 56 |
- end |
|
| 57 |
- |
|
| 58 | 52 |
def oauth_key |
| 59 |
- ENV["#{provider_to_env}_OAUTH_KEY"]
|
|
| 53 |
+ (config = Devise.omniauth_configs[provider.to_sym]) && config.args[0] |
|
| 60 | 54 |
end |
| 61 | 55 |
|
| 62 | 56 |
def oauth_secret |
| 63 |
- ENV["#{provider_to_env}_OAUTH_SECRET"]
|
|
| 57 |
+ (config = Devise.omniauth_configs[provider.to_sym]) && config.args[1] |
|
| 64 | 58 |
end |
| 65 | 59 |
|
| 66 | 60 |
def self.provider_specific_options(omniauth) |